package Day07;

import java.util.Scanner;

public class CalTotalAvg3 {
    public static void main(String[] args) {
        int Judges=6;
        double Remove=Remove(Scoringbyjudges(Judges));
        double average=average(Remove,Judges);
        System.out.println("最终得分为"+average);

    }
    public static  double[] Scoringbyjudges(int Judges){//该方法用于创建一个分数组
        Scanner scn=new Scanner(System.in);
        double[] Fractionalgroup=new double[Judges];//创建一个长度为评委人数的分数组
        for (int i=1;i<Fractionalgroup.length;i++){
            System.out.println("请第"+i+"位评委输入成绩");
            Fractionalgroup[i]=scn.nextDouble();

        }
        return Fractionalgroup;
    }
    public static double Remove(double[] Scoringbyjudges){
        double fraction=0.0;
        double max=0;
        double min=0;
        for (int i=0;i<Scoringbyjudges.length;i++){
            if (Scoringbyjudges[i]>max){
                max=Scoringbyjudges[i];
            }
            if (Scoringbyjudges[i]<min){
                min=Scoringbyjudges[i];
            }
            fraction+=Scoringbyjudges[i];//总分
        }
        fraction=fraction-max-min;
        System.out.println("去掉最大值和最小值的总分为"+fraction);
        return fraction;
    }
    public static double average(double fraction, int Judges){
       double average=fraction/Judges;
        System.out.println("平均分为"+average);
       return average;
    }

}
